package com.swit.mobile.jdf;

/*
 * ConfigurationException.java
 * Copyright 2012 by  SWIT, Inc.,
 * 512, Business Incubator Cener, Kangnam Univ.
 * All rights reserved.
 * 
 * NOTICE !      You can copy or redistribute this code freely, 
 * but you should not remove the information about the copyright notice 
 * and the author.
 * 
 * @author  DongJin Lee, swit.kenn@gmail.com
 */
public abstract class GeneralConfiguration implements Config{
	protected static Object lock = new Object();
	protected static java.util.Properties props = null;

	public GeneralConfiguration() throws ConfigurationException {
		super();
	}
	public String get(String key) {
		return getString(key);
	}
	public boolean getBoolean(String key) {
		boolean value = false;
		try {
			value = (new Boolean(props.getProperty(key))).booleanValue();
		}
		catch(Exception e){
			throw new IllegalArgumentException("Illegal Boolean Key : " + key);
		}
		return value;
	}
	public int getInt(String key) {
		int value = -1;
		try {
			value = Integer.parseInt(props.getProperty(key));
		}
		catch(Exception e){
			throw new IllegalArgumentException("Illegal Integer Key : " + key);
		}
		return value;
	}
	public java.util.Properties getProperties() {
		return props;
	}
	public String getString(String key) {
		String value = null;
		try {
			value = props.getProperty(key);
			if ( value == null ) throw new Exception("value of key(" +key+") is null" );

		}
		catch(Exception e){
			throw new IllegalArgumentException("Illegal String Key : " + key);
		}
		return value;
	}
}
